/**
 * 安装element-plus
 */
import { ElMessageBox } from 'element-plus'

class ElementUtil {
  static openBox = ({
    content,
    type = 'warning',
    buttonSize = 'small',
  }: {
    content: string
    type?: '' | 'success' | 'warning' | 'info' | 'error'
    buttonSize?: '' | 'default' | 'small' | 'large'
  }): Promise<boolean> => {
    return new Promise((resolve) => {
      ElMessageBox({
        title: '提示',
        message: content,
        type: type,
        showCancelButton: true,
        buttonSize: buttonSize,
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          resolve(true) // 用户点击了确定，返回 true
        })
        .catch(() => {
          resolve(false) // 用户点击了取消，返回 false
        })
    })
  }
}

export default ElementUtil
